// components/custom-navigator/customNavgator.js
const app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    getEnergyShow: {
      type: Boolean,
      value: false
    },
    signEnergyCount:{
      type: String,
      value: ''
    },
  },

  options: {
    addGlobalClass: true,
  },
  /**
   * 组件的初始数据
   */
  data: {
    CDNPATH:app.globalData.CDNPATH,
    energyTotal: 0
  },

  ready () {
    let energy = ''
    app.api.get({
      url: 'get_energy_detail'
    }).then(res => {
      energy = res.energy
      this.setData({
        energyTotal: Number(res.energy)-Number(this.data.signEnergyCount)
      })
    })
    const animation = wx.createAnimation({
      duration: 3000,
      timingFunction: 'ease',
    })
    setTimeout(() => {
      animation.translate3d(150,-210,-180).scale(0.2).opacity(0).step({
        duration:1000
      })
      this.setData({
        animate: animation.export()
      })
    }, 200)
    setTimeout(() => {
      this.setData({
        energyTotal: energy
      })
    }, 1200)
    setTimeout(() => {
      this.closeDialog()
    }, 1500)
  },

  /**
   * 组件的方法列表
   */
  methods: {
    closeDialog () {
      this.triggerEvent('closeDialog', {}, {})
    }
  }
})
